package guicommon;

import java.nio.CharBuffer;
import java.util.Hashtable;

public class Body {

    public static final String SOH = "\u0001";

    private Hashtable<String, String> mapKeyToValue = 
            new Hashtable(); 

    public Body() {
        mapKeyToValue = new Hashtable();
    }

    void AddField(String key, String value) {
        mapKeyToValue.put(key, value);
    }

    String GetField(String key) {
        if (mapKeyToValue.containsKey(key)) {
            return mapKeyToValue.get(key);
        }
        return null;
    }

    void ToCharSequence(CharBuffer result) {
        for (String key : mapKeyToValue.keySet()) {
            result.put(String.format("%s=%s%s",
                    key, mapKeyToValue.get(key), SOH));
        }
    }

}
